import request from '../../../util/request';
import {blog} from '../../../config/config';

function addBlog(title, content) {
    return request(blog('/api/blog/addBlog'), {
        data: {
            title: title,
            content: content,
        }
    });
}

function updateBlog(recordId, title, content) {
    return request(blog('/api/blog/updateBlog'), {
        data: {
        	recordId: recordId,
            title: title,
            content: content,
        }
    });
}

function removeBlog(recordId) {
    return request(blog('/api/blog/removeBlog'), {
        data: {
            recordId: recordId,
        }
    });
}

function getBlogByRecordId(recordId) {
    return request(blog('/api/blog/getBlogByRecordId'), {
        data: {
            recordId: recordId,
        }
    });
}

function pageBlogByUserId(userId, orderBy, pageNum, pageSize) {
    return request(blog('/api/blog/pageBlogByUserId'), {
        data: {
            userId: userId,
            orderBy: orderBy,
            pageNum: pageNum,
            pageSize: pageSize,
        }
    });
}

function addLabel(labelName) {
	return request(blog('/api/blog/addLabel'), {
        data: {
            labelName: labelName,
        }
    });
}

function removeLabel(labelId) {
	return request(blog('/api/blog/removeLabel'), {
        data: {
            labelId: labelId,
        }
    });
}

function listLabelByUserId(userId) {
	return request(blog('/api/blog/listLabelByUserId'), {
        data: {
            userId: userId,
        }
    });
}

function addLabelLink(recordId, labelId) {
	return request(blog('/api/blog/addLabelLink'), {
        data: {
            recordId: recordId,
            labelId: labelId,
        }
    });
}

function removeLabelLink(recordId, labelId) {
	return request(blog('/api/blog/removeLabelLink'), {
        data: {
            recordId: recordId,
            labelId: labelId,
        }
    });
}

function sortLabelByLabelIdList(labelIdList) {
	return request(blog('/api/blog/linkLabel'), {
        data: {
            labelIdList: labelIdList,
        }
    });
}

export {
    addBlog,
    updateBlog,
    removeBlog,
    getBlogByRecordId,
    pageBlogByUserId,
    addLabel,
    removeLabel,
    listLabelByUserId,
    addLabelLink,
    removeLabelLink,
    sortLabelByLabelIdList,
};